<!--卡牌组件-->
<template>
  <div @click="selected" :class="active?'pucker-active':'pucker'" :style="back?'background-image:url(\'/landlord/'+color+pucker.name+'.bmp\')':'background-image:url(\'/landlord/back.jpeg\')'"></div>
</template>

<script>
export default {
  name: "PuckerCard",
  props:{
    pucker:null,
    index:{required: true,type:Number},
    active:{default:false,type:Boolean},
    back:{default: true}
  },
  data(){
    return{
    }
  },
  computed:{
    color(){
      let sort = this.pucker.color;
      switch (sort){
        case -1:
          return "";
        case 0:
          return "方块";
        case 1:
          return "梅花";
        case 2:
          return "红桃";
        case 3:
          return "黑桃";
      }
    }
  },
  methods:{
    selected(){
      if(this.pucker.selected){
        return;
      }
      console.log(this.index);
      this.$emit("selectedPucker",this.index);
    }
  }
}
</script>

<style scoped>
.pucker{
  transition-duration: 0.3s;
  display: inline-block;
  border-radius: 5px;
  cursor: pointer;
  box-shadow: #515151 0px 0px 1px 1px;
  width: 71px;
  height: 96px;
  object-fit: cover;
  margin-left: -45px;
  transform: translateY(0px);
  background-size: contain;
}
.pucker:hover{
  box-shadow: #515151 0px 0px 2px 3px;
  transition-duration: 0.3s;
  display: inline-block;
  cursor: pointer;
  background-size: contain;
  border-radius: 5px;
  width: 71px;
  margin-left: -45px;
  height: 96px;
  object-fit: cover;
  transform: translateY(-5px);
  z-index: 5;
}
.pucker-active{
  transition-duration: 0.3s;
  display: inline-block;
  background-size: contain;
  cursor: pointer;
  border-radius: 5px;
  width: 71px;
  margin-left: -45px;
  height: 96px;
  object-fit: cover;
  box-shadow: #515151 0px 0px 4px 4px;
  transform: translateY(-10px);
  z-index: 5;
}
</style>